package cn.xiangxiang.controller;

import cn.xiangxiang.pojo.business.Ad;
import cn.xiangxiang.service.business.AdService;
import cn.xiangxiang.service.goods.CategoryService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
public class IndexController {

    @Reference
    private AdService adService;

    @Reference
    private CategoryService categoryService;

    @RequestMapping("/index")
    public String index(Model model){
        // 查询轮播广告
        List<Ad> adList = adService.findAdByPosition("web_index_lb");
        model.addAttribute("adlist",adList);
        // 小广告

        // 导航列表
        List<Map<String, Object>> categoryThree = categoryService.findCategoryTree();
        model.addAttribute("categoryTree",categoryThree);
        return "index";
    }
}
